<?php

class myUser extends sfBasicSecurityUser

{
		

  public function signIn($user)
  {
	
    $this->setAuthenticated(true);
    //get user permission
    
	$permissions = $user->getUser2Permissions();
	
	$userpermission = '';
	
	foreach ($permissions as $permission) {
	
    $this->getContext()->getUser()->addCredential($permission->getPermission());

	}

    $this->getContext()->getUser()->addCredential('user');

    
    $this->setAttribute('user_id', $user->getId(), 'user');
    $this->setAttribute('nickname', $user->getNickname(), 'user');
    $this->setAttribute('fullName', $user->getFirstName().' '.$user->getLastName(), 'user');
    $this->setAttribute('email', $user->getEmail(), 'user');

  }
   
  public function signOut()
  {
    $this->getAttributeHolder()->removeNamespace('user');
   
    $this->setAuthenticated(false);
    $this->clearCredentials();

  	sfContext::getInstance()->getResponse()->setCookie('devunityuid', '', time() - 3600, '/');
  }
  
   
  public function getSignedUserId()
  {
    return $this->getAttribute('user_id', '', 'user');
  }
  
  public function getNickname()
  {
    return $this->getAttribute('nickname', '', 'user');
  }
  
  public function getFullName()
  {
    return $this->getAttribute('fullName', '', 'user');
  }

 public function getUserEmail()
  {
    return $this->getAttribute('email', '', 'user');
  }


}

